package br.com.sgs.converter;

import br.com.sgs.basic.GenericDAO;
import br.com.sgs.persist.Obra;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

/**
 * @author MaUrO FiLhO
 */
public class ConverterObraTable implements Converter {

    public Object getAsObject(FacesContext fc, UIComponent uic, String string) {
        try{
        GenericDAO DAO = new GenericDAO();
       Obra obra =DAO.consultarObraByNome(string).get(0);
        return  obra;
        }catch(Exception Ex){
            System.out.print("Erro no GetasObject"+Ex);
            return null;
        }
    }

    public String getAsString(FacesContext fc, UIComponent uic, Object o) {
       try{
        Obra ob= (Obra) o;
        return ob.getNome();
        }catch(Exception Ex){
            System.out.print("Erro no GetasString"+Ex);
            return null;
        } 
    }

}
